<template>
  <!-- 遍历歌手的组件 -->
  <div class="singer_item">
    <div
      class="item"
      v-for="item in singers"
      :key="item.id"
      @click="singerItemClick(item)"
    >
      <img v-lazy="item.img1v1Url" :alt="item.name" class="pic_url" />
      <div class="singer_name">
        {{ item.name }}
      </div>
    </div>
  </div>
</template>

<script>
import { defineComponent, inject } from "vue";
export default defineComponent({
  name: "SingerItem",
  setup(props, context) {
    let singers = inject("singers");
    let singerItemClick = (item) => {
      context.emit("singerItemClick", item);
    };
    return {
      singers,
      singerItemClick,
    };
  },
});
</script>
<style scoped>
.singer_item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}
.item {
  width: 180px;
  margin: 20px 10px;
  cursor: pointer;
}
.pic_url {
  width: 180px;
  height: 180px;
  border-radius: 2px;
}
.singer_name {
  width: 100%;
  color: #222;
  font-size: 17px;
  text-align: center;
  margin-top: 10px;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}
</style>
